package core.dashboard;

import core.Pilot;

public class Dashboard
{
	protected Pilot pilot;
	private String testName;
	private String serverType;
	private String os;
	private String platform;
	private String browserName;
	private String browserVersion;
	private String siteUrl;
	private String proxy;
	private String saucelabsUsername;
	private String saucelabsKey;
	private String appiumPort;
	private String appiumUdid;
	private String appiumBootstrapPort;
	private String appiumChromedriverPort;
	private String siteURL;
	private int testStatus;
	private long testTimeStart = 0;
	private long testTimeEnd = 0;
	private long testTimeRun = 0;
	private String testDateStart = "0000-00-00 00:00:00";
	private String testDateEnd = "0000-00-00 00:00:00";;

	/**
	 * Constructor
	 * @param p_pilot
	 */
	public Dashboard(Pilot p_pilot)
	{
		pilot = p_pilot;
	}

	/**
	 * Prints data model fields
	 */
	public void print()
	{
		pilot.log().info("Server: " + getServerType());
		pilot.log().info("OS: " + getOS());
		pilot.log().info("Platform: " + getPlatform());
		pilot.log().info("Browser name: " + getBrowserName());
		pilot.log().info("Browser version: " + getBrowserVersion());
		pilot.log().info("Site: " + getSiteUrl());
		pilot.log().info("Proxy: " + getProxy());
		pilot.log().info("SauceLabs username: " + getSaucelabsUsername());
		pilot.log().info("SauceLabs key: " + getSaucelabsKey());
	}

	public Dashboard setAppiumChromedriverPort(String p_appiumChromedriverPort)
	{
		appiumChromedriverPort = p_appiumChromedriverPort;

		return this;
	}

	public String getAppiumChromedriverPort()
	{
		if (appiumChromedriverPort == null)
		{
			pilot.log().warn("'appiumChromedriverPort' is not initialized");
		}

		return appiumChromedriverPort;
	}

	public Dashboard setAppiumBootstrapPort(String p_appiumBootstrapPort)
	{
		appiumBootstrapPort = p_appiumBootstrapPort;

		return this;
	}

	public String getAppiumBootstrapPort()
	{
		if (appiumBootstrapPort == null)
		{
			pilot.log().warn("'appiumBootstrapPort' is not initialized");
		}

		return appiumBootstrapPort;
	}

	public Dashboard setAppiumUdid(String p_appiumUdid)
	{
		appiumUdid = p_appiumUdid;

		return this;
	}

	public String getAppiumUdid()
	{
		if (appiumUdid == null)
		{
			pilot.log().warn("'appiumUdid' is not initialized");
		}

		return appiumUdid;
	}

	public Dashboard setAppiumPort(String p_appiumPort)
	{
		appiumPort = p_appiumPort;

		return this;
	}

	public String getAppiumPort()
	{
		if (appiumPort == null)
		{
			pilot.log().warn("'appiumPort' is not initialized");
		}

		return appiumPort;
	}

	public String getTestName()
	{
		if (testName == null)
		{
			pilot.log().warn("'testName' is not initialized");
		}

		return testName;
	}

	public Dashboard setTestName(String p_testName)
	{
		testName = p_testName;

		return this;
	}

	public String getServerType()
	{
		if (serverType == null)
		{
			pilot.log().warn("'serverType' is not initialized");
		}

		return serverType;
	}

	public Dashboard setServerType(String p_serverType)
	{
		serverType = p_serverType;
		return this;
	}

	public String getOS()
	{
		if (os == null)
		{
			pilot.log().warn("'os' is not initialized");
		}

		return os;
	}

	public Dashboard setOS(String p_os)
	{
		os = p_os;
		return this;
	}

	public String getPlatform()
	{
		if (platform == null)
		{
			pilot.log().warn("'platform' is not initialized");
		}

		return platform;
	}

	public Dashboard setPlatform(String p_platform)
	{
		platform = p_platform;
		return this;
	}

	public String getBrowserName()
	{
		if (browserName == null)
		{
			pilot.log().warn("'browserName' is not initialized");
		}

		return browserName;
	}

	public Dashboard setBrowserName(String p_browserName)
	{
		browserName = p_browserName;
		return this;
	}

	public String getBrowserVersion()
	{
		if (browserVersion == null)
		{
			pilot.log().warn("'browserVersion' is not initialized");
		}

		return browserVersion;
	}

	/**
	 * Sets a test browser version
	 * @param p_browserVersion Browser version
	 * @return TestDataModel instance
	 */
	public Dashboard setBrowserVersion(String p_browserVersion)
	{
		browserVersion = p_browserVersion;
		return this;
	}

	public String getSiteUrl()
	{
		if (siteUrl == null)
		{
			pilot.log().warn("'siteUrl' is not initialized");
		}

		return siteUrl;
	}

	public Dashboard setSiteUrl(String p_siteUrl)
	{
		siteUrl = p_siteUrl;
		return this;
	}

	/**
	 * Gets a test proxy
	 * @return Test proxy
	 */
	public String getProxy()
	{
		if (proxy == null)
		{
			pilot.log().warn("'proxy' is not initialized");
		}

		return proxy;
	}

	/**
	 * Sets a test proxy
	 * @return TestDataModel instance
	 */
	public Dashboard setProxy(String p_proxy)
	{
		proxy = p_proxy;
		return this;
	}

	/**
	 * Gets Sauce Labs user name
	 * @return Sauce Labs user name
	 */
	public String getSaucelabsUsername()
	{
		if (saucelabsUsername == null)
		{
			pilot.log().warn("'saucelabsUsername' is not initialized");
		}

		return saucelabsUsername;
	}

	/**
	 * Sets a Sauce Labs user name
	 * @param p_saucelabsUsername Sauce Labs user name
	 * @return TestDataModel instance
	 */
	public Dashboard setSaucelabsUsername(String p_saucelabsUsername)
	{
		saucelabsUsername = p_saucelabsUsername;
		return this;
	}

	/**
	 * Gets Sauce Labs user key
	 * @return Sauce Labs user key
	 */
	public String getSaucelabsKey()
	{
		if (saucelabsKey == null)
		{
			pilot.log().warn("'saucelabsKey' is not initialized");
		}

		return saucelabsKey;
	}

	/**
	 * Sets Sauce Labs user key
	 * @param p_saucelabsKey Sauce Labs user key
	 * @return TestDataModel instance
	 */
	public Dashboard setSaucelabsKey(String p_saucelabsKey)
	{
		saucelabsKey = p_saucelabsKey;
		return this;
	}

	/**
	 * Gets a test site URL
	 * @return Test site URL
	 */
	public String getSiteURL()
	{
		if (siteURL == null)
		{
			pilot.log().warn("'siteURL' is not initialized");
		}

		return siteURL;
	}

	public Dashboard setSiteURL(String p_siteURL)
	{
		siteURL = p_siteURL;

		return this;
	}

	/**
	 * Gets test runtime
	 * @return Test runtime
	 */
	public long getTimeRun()
	{
		return testTimeRun;
	}

	/**
	 * Sets test runtime
	 * @param p_timeRun Test runtime
	 * @return TestDataModel instance
	 */
	public Dashboard setTimeRun(long p_timeRun)
	{
		testTimeRun = p_timeRun;

		return this;
	}

	/**
	 * Gets test start date
	 * @return Test start date
	 */
	public String getDateStart()
	{
		if (testDateStart == null)
		{
			pilot.log().warn("'dateStart' is not initialized");
		}

		return testDateStart;
	}

	/**
	 * Sets test start date
	 * @param p_dateStart Test start date
	 * @return TestDataModel instance
	 */
	public Dashboard setDateStart(String p_dateStart)
	{
		testDateStart = p_dateStart;

		return this;
	}

	/**
	 * Gets test end date
	 * @return Test end date
	 */
	public String getDateEnd()
	{
		if (testDateEnd == null)
		{
			pilot.log().warn("'dateEnd' is not initialized");
		}

		return testDateEnd;
	}

	/**
	 * Sets test start date
	 * @return TestDataModel instance
	 */
	public Dashboard setDateEnd(String p_dateEnd)
	{
		testDateEnd = p_dateEnd;

		return this;
	}

	/**
	 * Gets test status
	 * @return Test status
	 */
	public int getStatus()
	{
		if (testStatus == 0)
		{
			pilot.log().info("'status' is not initialized");
		}

		return testStatus;
	}

	/**
	 * Sets test status
	 * @param p_status Test status ID
	 * @return TestDataModel instance
	 */
	public Dashboard setStatus(int p_status)
	{
		testStatus = p_status;

		return this;
	}

	/**
	 * Gets test start time
	 * @return Start time
	 */
	public long getTimeStart()
	{
		return testTimeStart;
	}

	/**
	 * Sets test start time
	 * @return TestDataModel instance
	 */
	public Dashboard setTimeStart(long p_timeStart)
	{
		testTimeStart = p_timeStart;

		return this;
	}

	/**
	 * Gets test end time
	 * @return End time
	 */
	public long getTimeEnd()
	{
		return testTimeEnd;
	}

	/**
	 * Sets test end time
	 * @return TestDataModel instance
	 */
	public Dashboard setTimeEnd(long p_timeEnd)
	{
		testTimeEnd = p_timeEnd;

		return this;
	}
}
